<?php
class Tool{
	static function _removeCache($name){
		$cache = new Cache_request();
		$cache->remove($name);
	}
	static function _getCache($name){
		$cache = new Cache_request();
		if($cache->has($name)){
			return $cache->get($name);
		}else{
			return "";
		}
	}
	static function _setCache($name,$value){
		$cache = new Cache_request();
		$cache->set($name,$value);
	}
	static function _setCookie($name,$value){
		setcookie($name,$value,time()+3600,'/');
	}
	static function _removeCookie($name){
		setcookie($name,'',time()-3600,'/');
	}
	static function _setSession($name,$value){
		if(!isset($_SESSION)){
			session_start();
		}
		$_SESSION[$name] = $value;
	}
	static function _getSession($name){
		if(!isset($_SESSION)){
			session_start();
		}
		return isset($_SESSION[$name])?$_SESSION[$name]:'';
	}
	static function _removeAllSession(){
		if(!isset($_SESSION)){
			session_start();
		}
		session_destroy();
	}
	/**
	  *字符串转换为数组,以半角逗号分割
	  *@param $str 需要处理的字符串
	  *@param $delimiter 分隔符，默认','
	  *@return 返回转换后的字符串
	  */
	static public function strToArray($str,$delimiter=','){
		if($str == '') return array();
		$str = trim(trim($str),$delimiter);
		return explode($delimiter,$str);
	}
}
?>
